<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script src="./js/axios.js"></script>
    <script>
         var token = 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6OCwidXNlcm5hbWUiOiJ5YXN1b3p1aWt1IiwicGFzc3dvcmQiOiIiLCJuaWNrbmFtZSI6bnVsbCwiZW1haWwiOm51bGwsInVzZXJfcGljIjoiIiwiaWF0IjoxNjE2MTUzNTc0LCJleHAiOjE2MTYxODk1NzR9.DxmqM639mj4OiOtknbkFga5r2CqlLKloQSdAB5O9Uk8'
         
        axios.interceptors.request.use( config => {
        console.log(config.url)
        config.headers.Authorization = token
        console.log('获取数据请求前拦截成功');
        return config;
        }, err => {
        console.log(err)
        })


        //请求拦截
        axios.interceptors.request.use(config => {
            //请求发送之前处理的数据

            return config
        }),err=>{
            console.log(err);
        }

        //响应拦截
        axios.interceptors.response.use( results => {

            //请求返回之前修改的数据
            return results
        })

        axios.interceptors.response.use( result => {
            result.data.message = '我修改的'
            console.log('数据返回前处理');
            return result
        }),err => {
            console.log(err);
        }

        axios.defaults.baseURL='http://localhost:8000'
        axios.get('/my/article/cates').then( res => {
            console.log(res.data);
        }) 



       
    </script>
</body>
</html>